using System.Collections.Generic;
using System.Linq;
using UnityEngine;

[CreateAssetMenu(fileName = "Condition15-技能范围内无友军", menuName = "Skill/Condition/Condition15-技能范围内无友军", order = 15)]
public class Condition15 : ConditionBase
{
    public override bool Evaluate(Pair pair,GameEvent e)
    {
        var chess = pair.Chess;
        var chessList = ChessManager.GetInstance().chessList;
        var enemyChess = chessList.Where(c => c.GetChessSide() == chess.GetChessSide()).ToList();
        var targetPositions =
            chess.GetChessSide() == ChessSide.Player1
                ? chess.chessDate.skillRange.rangeType == RangeType.Normal
                    ? Math.GetTargetPosition(chess.ChessDetail.Position,
                        chess.chessDate.skillRange.vector2IntMode)
                    : chess.chessDate.skillRange.vector2IntMode
                : chess.chessDate.skillRange.rangeType == RangeType.Normal
                    ? Math.GetEnemyTargetPosition(chess.ChessDetail.Position,
                        chess.chessDate.skillRange.vector2IntMode)
                    : chess.chessDate.skillRange.vector2IntMode;
        var targets = (from targetChess in enemyChess
            where targetPositions.Contains(targetChess.ChessDetail.Position)
            select targetChess).ToList();
        if(targets.Count == 0) return true;
        return false;
    }
}